import request from "@/utils/request";

//1.获取分页列表
//获取分页列表参数类型
export interface reqTrademarkListParamType {
    page: number;
    limit: number;
}
//返回值中records的每一项
export interface reqTrademarkReturnRecordsItemType extends reqAddTrademarkParamType{
    id: number;
}
//返回值中records
export type reqTrademarkReturnRecordsType = reqTrademarkReturnRecordsItemType[]
//返回值类型
export interface reqTrademarkReturnType {
    records: reqTrademarkReturnRecordsType;
    total: number;
    size: number;
    current: number;
    searchCount: boolean;
    pages: number;
}
//请求分页列表
export const requestTrademarkList = ({
    page,
    limit,
}: reqTrademarkListParamType) => {
    return request.get<any,reqTrademarkReturnType>(`/admin/product/baseTrademark/${page}/${limit}`);
};


//2.新增品牌
//新增品牌参数类型
export interface reqAddTrademarkParamType{
    tmName:string,
    logoUrl:string
}
//请求新增品牌
export const requestAddTrademark = (trademark:reqAddTrademarkParamType) => {
    return request.post<any,null>('/admin/product/baseTrademark/save',trademark)
}

//3.修改品牌
export const requestUpdateTrademark = (trademark: reqTrademarkReturnRecordsItemType) => {
    return request.put<any,null>('/admin/product/baseTrademark/update',trademark)
}

//4.删除品牌
export const requestDeleteTrademark = (id:number) => {
    return request.delete<any,null>(`/admin/product/baseTrademark/remove/${id}`)
}
//5.获取全部品牌列表
export const requestAllTrademark = () => {
    return request.get<any,reqTrademarkReturnRecordsType>('/admin/product/baseTrademark/getTrademarkList')
}